import { Component, OnInit } from '@angular/core';
import { StorageService } from '../../service/storage.service'
import { CommonService } from '../../service/common.service'

@Component({
  selector: 'app-nodelist',
  templateUrl: './nodelist.page.html',
  styleUrls: ['./nodelist.page.scss'],
})
export class NodelistPage implements OnInit {

  constructor(private storage:StorageService,private common:CommonService) { }

  public list:any[] = [];
  public page:number = 1
  public limit:number = 10
  public flag:boolean = false

  ngOnInit() {
    this.PayDetail()
  }

  // 获取充值明细
  PayDetail(){
    var api = '/tbr/bzz/getNodeList?page='+this.page+'&limit='+this.limit
    var params = {
      // userId:this.common.getInfo().userId
    }
    console.log(this.page)
    this.common.get(api).then((res:any)=>{
      if(res.code == 200){
        for(var i=0;i<res.data.records.length;i++){
          this.list.push(res.data.records[i])
        }
        if(res.data.records.length < this.limit){
          this.flag = true
        }
      }
    })
  }

  loadData(event){
    if (this.flag == true) {
      event.target.disabled = true;
      return
    }
  setTimeout(()=>{
    this.page += 1;
    this.PayDetail()
    event.target.complete();
  },700)
}

}
